using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using MEA.AE_BusinessLogic.Properties;
using MEA.AE_Data;
using MEA.AE_Data.Config;
using MEA.Chart;

namespace MEA.AE_BusinessLogic
{
	public abstract class UIGraphBase : UserControl, IDisposable
	{
		public enum Mode
		{
			stay,
			run,
			cursor,
			zoom,
			noupdate
		}

		public enum StartStopMode
		{
			tozero,
			goahead
		}

		protected enum Triggerstati
		{
			normalrun,
			waittrigger,
			triggerfired
		}

		private delegate void AddDelComboItemCallback();

		private delegate void dbg_Label3SetTexT();

		protected delegate void dbg_setscroll();

		public delegate void SaveHandler(object logpath, ArrayList functs);

		public struct CheckedSigVals
		{
			public bool checkedStatus;

			public string sigName;

			public string sigVal;

			public Color chkBoxColor;
		}

		private IContainer components;

		protected ServiceLayer serviceLayer;

		protected ECU_Data ecuA;

		protected ECU_Data ecuB;

		protected int xmin;

		protected int xmax = 10;

		protected bool cursorx;

		protected bool cursory;

		protected int dataupdatetime;

		protected ArrayList functs;

		protected Hashtable functs_hash;

		protected Graph graph;

		protected ImageList il;

		protected bool isdraw;

		protected ArrayList koordsysts;

		protected Mode mode;

		protected Panel panel1;

		protected PictureBox pictBox1;

		protected HScrollBar hScrollBar1;

		protected PropertyGrid propgrid;

		protected bool run;

		protected Function selectedfunct;

		protected PointF selectedpoint;

		protected StartStopMode startstopmode;

		protected float tend;

		protected bool triggersingle;

		protected ToolStrip toolStrip1;

		private ToolStripButton toolStripButtonLeft;

		private ToolStripButton toolStripButtonRight;

		private ToolStripButton toolStripButtonUp;

		private ToolStripButton toolStripButtonDown;

		private ToolStripSeparator toolStripSeparator1;

		private ToolStripLabel toolStripLabel1;

		private ToolStripButton toolStripButtonPlusX;

		private ToolStripButton toolStripButtonMinusX;

		private ToolStripSeparator toolStripSeparator2;

		private ToolStripLabel toolStripLabel2;

		private ToolStripButton toolStripButtonPlusY;

		private ToolStripButton toolStripButtonMinusY;

		private ToolStripSeparator toolStripSeparator3;

		private ToolStripLabel toolStripLabel3;

		public ToolStripComboBox toolStripComboBoxStep;

		private ToolStripLabel toolStripLabel4;

		private ToolStripSeparator toolStripSeparator4;

		public ToolStripButton toolStripButtonStop;

		public ToolStripButton toolStripButtonRecord;

		protected ToolStripButton toolStripButtonExport;

		private ToolStripButton toolStripButtonShiftLeft;

		private ToolStripButton toolStripButtonShiftRight;

		protected ToolStripButton toolStripButtonFileInfo;

		protected ToolStripLabel toolStripLabelLiveView;

		protected DataGridView checkedDataGridViewGraphSignals;

		protected DataGridViewCheckBoxColumn dataGridViewSignalCheckBoxCol;

		protected DataGridViewTextBoxColumn dataGridViewSignalNameCol;

		protected DataGridViewTextBoxColumn dataGridViewSignalValueCol;

		private ToolStripSeparator toolStripSeparator5;

		private ToolStripSeparator toolStripSeparator6;

		protected ToolStripSeparator toolStripSeparator7;

		protected ToolStripComboBox toolStripComboBoxLeadinOut;

		protected ToolStripButton toolStripButtonShowLInOut;

		public FileInfoHnd fileInfo;

		private int myDataPos = -1;

		public int myListNr;

		private ArrayList graphVars;

		private Hashtable graphVars_hash;

		public ConfigBase.EGraphicAspect graphicAspect;

		private bool SetSessionMarker = true;

		public List<RecManLeadInOut.SLeadInOutInfo> leadInOutListA;

		public List<RecManLeadInOut.SLeadInOutInfo> leadInOutListB;

		private string myFileName;

		public List<CheckedSigVals> checkedSigIx = new List<CheckedSigVals>();

		public CaCrDisplay CaCrDisplayA;

		public CaCrDisplay CaCrDisplayB;

		private bool CaCrTested;

		protected ConfigData.e_ECUS activeECU;

		[Description("Backgroundcolor")]
		[Category("Style")]
		public Color BgColor
		{
			get
			{
				return graph.BgColor;
			}
			set
			{
				graph.BgColor = value;
			}
		}

		[Description("Mode")]
		[Category("Data")]
		public Mode Graphmode
		{
			get
			{
				return mode;
			}
			set
			{
				mode = value;
				if (mode == Mode.noupdate)
				{
					isdraw = false;
				}
				else
				{
					isdraw = true;
				}
			}
		}

		public ArrayList GraphVars
		{
			get
			{
				return graphVars;
			}
			set
			{
				graphVars = value;
			}
		}

		public Hashtable GraphVars_hash
		{
			get
			{
				return graphVars_hash;
			}
			set
			{
				graphVars_hash = value;
			}
		}

		public Graph Graph
		{
			get
			{
				throw new NotImplementedException();
			}
		}

		public string MyFileName
		{
			get
			{
				return myFileName;
			}
			set
			{
				myFileName = value;
			}
		}

		public event SaveHandler SaveButtonPressed;

		public event EventHandler AbortThread;

		public void Addvar(Var vari)
		{
			int cnt = 0;
			if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphDataLog)
			{
				return;
			}
			CheckedSigVals vals;
			checkedDataGridViewGraphSignals.Invoke((MethodInvoker)delegate
			{
				cnt = checkedDataGridViewGraphSignals.Rows.Add(checkedSigIx.Count - 1);
				cnt++;
				for (int i = 0; i < cnt; i++)
				{
					vals = checkedSigIx[i];
					checkedDataGridViewGraphSignals.Rows[i].Cells[0].Style.BackColor = vals.chkBoxColor;
					checkedDataGridViewGraphSignals.Rows[i].Cells[1].Value = vals.sigName;
					checkedDataGridViewGraphSignals.Rows[i].Cells[2].Value = vals.sigVal;
				}
			});
			lock (GraphVars.SyncRoot)
			{
				lock (GraphVars_hash.SyncRoot)
				{
					lock (koordsysts.SyncRoot)
					{
						for (int num = 0; num < GraphVars.Count; num++)
						{
							Var varx = (Var)GraphVars[num];
							Koordsyst koordsyst = null;
							bool flag = true;
							for (int num2 = 0; num2 < koordsysts.Count; num2++)
							{
								if (((Koordsyst)koordsysts[num2]).koordvar == varx)
								{
									koordsyst = (Koordsyst)koordsysts[num2];
									flag = false;
									break;
								}
							}
							if (flag)
							{
								koordsyst = GenerateNewKoord(0f, tend, varx.Min, varx.Max, varx.yscal, null, varx.SigClass, varx.Format, varx.LineColor);
								foreach (Koordsyst koordsyst2 in koordsysts)
								{
									koordsyst2.XAxe = false;
								}
								koordsysts.Add(koordsyst);
							}
							Function function = new Function(koordsyst, ref varx, "dd.MM.yy HH:mm:ss.f", 1000);
							lock (functs.SyncRoot)
							{
								functs.Add(function);
								functs_hash.Add(varx.Name, function);
								graph.AddFunction(function);
								if (selectedfunct != null)
								{
									selectedfunct.Visible = false;
									selectedfunct.DeSelect();
								}
								selectedfunct = function;
							}
						}
					}
				}
			}
		}

		public void Addvar()
		{
			CheckedSigVals vals;
			lock (GraphVars.SyncRoot)
			{
				lock (GraphVars_hash.SyncRoot)
				{
					lock (koordsysts.SyncRoot)
					{
						for (int i = 0; i < graphVars.Count; i++)
						{
							Var varx = (Var)graphVars[i];
							vals = default(CheckedSigVals);
							vals.chkBoxColor = varx.LineColor;
							vals.sigName = varx.Name;
							if (i == 0)
							{
								vals.checkedStatus = true;
							}
							checkedSigIx.Add(vals);
							Koordsyst koordsyst = null;
							bool flag = true;
							for (int j = 0; j < koordsysts.Count; j++)
							{
								if (((Koordsyst)koordsysts[j]).koordvar == varx)
								{
									koordsyst = (Koordsyst)koordsysts[j];
									flag = false;
									break;
								}
							}
							if (flag)
							{
								koordsyst = GenerateNewKoord(0f - tend, 0f, varx.Min, varx.Max, varx.yscal, null, varx.SigClass, varx.Format, varx.LineColor);
								foreach (Koordsyst koordsyst2 in koordsysts)
								{
									koordsyst2.XAxe = false;
								}
								koordsysts.Add(koordsyst);
							}
							Function function = new Function(koordsyst, ref varx, "dd.MM.yy HH:mm:ss", 1000);
							lock (functs.SyncRoot)
							{
								functs.Add(function);
								functs_hash.Add(varx.Name, function);
								graph.AddFunction(function);
								if (selectedfunct != null)
								{
									selectedfunct.Visible = false;
									selectedfunct.DeSelect();
								}
								selectedfunct = function;
							}
						}
					}
				}
			}
			checkedDataGridViewGraphSignals.Invoke((MethodInvoker)delegate
			{
				checkedDataGridViewGraphSignals.Rows.Add(checkedSigIx.Count - 1);
				for (int k = 0; k < checkedSigIx.Count; k++)
				{
					vals = checkedSigIx[k];
					checkedDataGridViewGraphSignals.Rows[k].Cells[0].Style.BackColor = vals.chkBoxColor;
					checkedDataGridViewGraphSignals.Rows[k].Cells[1].Value = vals.sigName;
				}
			});
		}

		protected void checkedDataGridViewGraphSignals_CellContentClick(object sender, DataGridViewCellMouseEventArgs e)
		{
			if (checkedSigIx.Count <= 0)
			{
				return;
			}
			int rowIndex = e.RowIndex;
			if (rowIndex < 0)
			{
				return;
			}
			CheckedSigVals value = checkedSigIx[rowIndex];
			if (e.ColumnIndex == 0 && e.Button == MouseButtons.Right)
			{
				ColorDialog colorDialog = new ColorDialog();
				colorDialog.AllowFullOpen = false;
				colorDialog.ShowHelp = true;
				colorDialog.Color = value.chkBoxColor;
				if (colorDialog.ShowDialog() == DialogResult.OK)
				{
					value.chkBoxColor = colorDialog.Color;
					checkedDataGridViewGraphSignals.Rows[rowIndex].Cells[0].Style.BackColor = value.chkBoxColor;
					checkedSigIx[rowIndex] = value;
					CheckedListBoxSignalsItemCheckChColour(rowIndex);
				}
			}
		}

		private void checkedDataGridViewGraphSignals_CellEventHandler(object sender, DataGridViewCellEventArgs e)
		{
			if (checkedSigIx.Count <= 0)
			{
				return;
			}
			int rowIndex = e.RowIndex;
			if (rowIndex < 0)
			{
				return;
			}
			CheckedSigVals value = checkedSigIx[rowIndex];
			lock (checkedSigIx)
			{
				if ((bool)checkedDataGridViewGraphSignals.Rows[rowIndex].Cells[0].EditedFormattedValue)
				{
					checkedDataGridViewGraphSignals.Rows[rowIndex].Cells[0].Value = false;
					value.checkedStatus = false;
					checkedSigIx[rowIndex] = value;
				}
				else
				{
					checkedDataGridViewGraphSignals.Rows[rowIndex].Cells[0].Value = true;
					value.checkedStatus = true;
					checkedSigIx[rowIndex] = value;
				}
			}
			CheckedListBoxSignalsItemCheck(rowIndex);
		}

		protected void CheckedListBoxSignalsItemCheckChColour(int index)
		{
			lock (koordsysts.SyncRoot)
			{
				Function function = (Function)functs[index];
				Koordsyst koordsyst = (Koordsyst)koordsysts[index];
				if (checkedSigIx[index].checkedStatus)
				{
					function.PenColor = checkedSigIx[index].chkBoxColor;
					koordsyst.KoordColor = checkedSigIx[index].chkBoxColor;
				}
				else
				{
					function.PenColor = checkedSigIx[index].chkBoxColor;
					koordsyst.KoordColor = checkedSigIx[index].chkBoxColor;
				}
				functs[index] = function;
				koordsysts[index] = koordsyst;
			}
			RedrawAll(true);
		}

		protected void CheckedListBoxSignalsItemCheck(int index)
		{
			try
			{
				lock (functs.SyncRoot)
				{
					lock (koordsysts.SyncRoot)
					{
						Function function = (Function)functs[index];
						Koordsyst koordsyst = (Koordsyst)koordsysts[index];
						if (checkedSigIx[index].checkedStatus)
						{
							function.Visible = true;
							koordsyst.YAxe = true;
						}
						else
						{
							function.Visible = false;
							koordsyst.YAxe = false;
						}
						List<Koordsyst> list = new List<Koordsyst>();
						bool flag = false;
						for (int i = 0; i < checkedSigIx.Count; i++)
						{
							if (!checkedSigIx[i].checkedStatus)
							{
								continue;
							}
							koordsyst = (Koordsyst)koordsysts[i];
							flag = false;
							foreach (Koordsyst item in list)
							{
								if (item.YMin == koordsyst.YMin && item.YMax == koordsyst.YMax && item.YAxeText == koordsyst.YAxeText)
								{
									flag = true;
									break;
								}
							}
							koordsyst.KoordColor = checkedSigIx[i].chkBoxColor;
							if (!flag)
							{
								list.Add(koordsyst);
							}
						}
						foreach (Koordsyst koordsyst6 in koordsysts)
						{
							koordsyst6.YAxe = false;
							koordsyst6.YAxeOffset = 30f;
						}
						int num = 0;
						for (int j = 0; j < list.Count; j++)
						{
							Koordsyst koordsyst3 = list[j];
							if ((double)koordsyst3.YMax > Math.Pow(2.0, 16.0) - 1.0)
							{
								num += 40;
							}
							koordsyst3.YAxeOffset = (j + 1) * 30 + num;
							koordsyst3.YAxe = true;
						}
						float num2 = 0f;
						foreach (Koordsyst koordsyst7 in koordsysts)
						{
							if (koordsyst7.YAxeOffset > num2)
							{
								num2 = koordsyst7.YAxeOffset;
							}
							koordsyst7.Offset = new PointF(num2, 25f);
						}
						foreach (Koordsyst koordsyst8 in koordsysts)
						{
							koordsyst8.Offset = new PointF(num2, 25f);
						}
					}
				}
				RedrawAll(true);
			}
			catch (ArgumentOutOfRangeException ex)
			{
				Console.WriteLine("CheckedListBoxSignalsItemCheck + index= " + index + " Message +" + ex.Message);
			}
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (components != null)
				{
					run = false;
					components.Dispose();
				}
				graph.Dispose();
				functs_hash.Clear();
				functs.Clear();
				functs.TrimToSize();
				koordsysts.Clear();
				koordsysts.TrimToSize();
				functs_hash = null;
				functs = null;
				koordsysts = null;
				checkedDataGridViewGraphSignals.Rows.Clear();
				if (fileInfo != null)
				{
					fileInfo.Disp();
				}
			}
			base.Dispose(disposing);
		}

		public Koordsyst GenerateNewKoord(float x_min, float x_max, float y_min, float y_max, double yscal, Var koordvar, ConfigLiveViewBase.ELiveViewSigClass sigclass, ConfigBase.EStringFormat format, Color c)
		{
			Koordsyst koordsyst = new Koordsyst(new Size(graph.Width, graph.Height), x_min, x_max, y_min, y_max, 30, format);
			koordsyst.XKoordRaster = true;
			koordsyst.YKoordRaster = true;
			koordsyst.AlwaysXAxe = true;
			koordsyst.AlwaysYAxe = true;
			koordsyst.YScal = yscal;
			koordsyst.YKoordAxes = false;
			koordsyst.YAxeText = ConfigLiveView.SigClass[(int)sigclass].Unit;
			koordsyst.koordvar = koordvar;
			koordsyst.KoordColor = c;
			koordsyst.YAxeOffset = 30f;
			for (int i = 0; i < koordsysts.Count; i++)
			{
				((Koordsyst)koordsysts[i]).Offset = new PointF(30f, 25f);
				((Koordsyst)koordsysts[i]).YAxeOffset = 30f;
			}
			koordsyst.XKoordSkalierung = true;
			koordsyst.XKoordRaster = false;
			koordsyst.YKoordSkalierung = true;
			return koordsyst;
		}

		protected void HScrollBar1_Scroll(object sender, ScrollEventArgs e)
		{
			hScrollBar1.Scroll -= HScrollBar1_Scroll;
			if (hScrollBar1.Focus() && e.OldValue != e.NewValue)
			{
				int num = e.NewValue - e.OldValue;
				lock (koordsysts.SyncRoot)
				{
					foreach (Koordsyst koordsyst in koordsysts)
					{
						if (num < 0)
						{
							if (hScrollBar1.Value > hScrollBar1.Minimum && hScrollBar1.Value + num < hScrollBar1.Minimum)
							{
								num = hScrollBar1.Minimum - (int)koordsyst.XMin;
							}
						}
						else if (hScrollBar1.Value < hScrollBar1.Maximum && hScrollBar1.Value + num > hScrollBar1.Maximum)
						{
							num = hScrollBar1.Maximum - (int)koordsyst.XMax + 50;
						}
						koordsyst.offsetWert(num, 0f);
					}
				}
				hScrollBar1.Value += num;
				RedrawAll(true);
			}
			hScrollBar1.Scroll += HScrollBar1_Scroll;
		}

		protected void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MEA.AE_BusinessLogic.UIGraphBase));
			this.il = new System.Windows.Forms.ImageList(this.components);
			this.hScrollBar1 = new System.Windows.Forms.HScrollBar();
			this.pictBox1 = new System.Windows.Forms.PictureBox();
			this.toolStrip1 = new System.Windows.Forms.ToolStrip();
			this.toolStripButtonLeft = new System.Windows.Forms.ToolStripButton();
			this.toolStripButtonRight = new System.Windows.Forms.ToolStripButton();
			this.toolStripButtonUp = new System.Windows.Forms.ToolStripButton();
			this.toolStripButtonDown = new System.Windows.Forms.ToolStripButton();
			this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
			this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
			this.toolStripButtonPlusX = new System.Windows.Forms.ToolStripButton();
			this.toolStripButtonMinusX = new System.Windows.Forms.ToolStripButton();
			this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
			this.toolStripLabel2 = new System.Windows.Forms.ToolStripLabel();
			this.toolStripButtonPlusY = new System.Windows.Forms.ToolStripButton();
			this.toolStripButtonMinusY = new System.Windows.Forms.ToolStripButton();
			this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
			this.toolStripLabel3 = new System.Windows.Forms.ToolStripLabel();
			this.toolStripComboBoxStep = new System.Windows.Forms.ToolStripComboBox();
			this.toolStripLabel4 = new System.Windows.Forms.ToolStripLabel();
			this.toolStripButtonShiftLeft = new System.Windows.Forms.ToolStripButton();
			this.toolStripButtonShiftRight = new System.Windows.Forms.ToolStripButton();
			this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
			this.toolStripButtonStop = new System.Windows.Forms.ToolStripButton();
			this.toolStripButtonRecord = new System.Windows.Forms.ToolStripButton();
			this.toolStripButtonExport = new System.Windows.Forms.ToolStripButton();
			this.toolStripLabelLiveView = new System.Windows.Forms.ToolStripLabel();
			this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
			this.toolStripComboBoxLeadinOut = new System.Windows.Forms.ToolStripComboBox();
			this.toolStripButtonShowLInOut = new System.Windows.Forms.ToolStripButton();
			this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
			this.toolStripButtonFileInfo = new System.Windows.Forms.ToolStripButton();
			this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
			this.checkedDataGridViewGraphSignals = new System.Windows.Forms.DataGridView();
			this.dataGridViewSignalCheckBoxCol = new System.Windows.Forms.DataGridViewCheckBoxColumn();
			this.dataGridViewSignalNameCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.dataGridViewSignalValueCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
			((System.ComponentModel.ISupportInitialize)this.pictBox1).BeginInit();
			this.toolStrip1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)this.checkedDataGridViewGraphSignals).BeginInit();
			base.SuspendLayout();
			this.il.ImageStream = (System.Windows.Forms.ImageListStreamer)resources.GetObject("il.ImageStream");
			this.il.TransparentColor = System.Drawing.Color.Transparent;
			this.il.Images.SetKeyName(0, "record.jpg");
			this.il.Images.SetKeyName(1, "stop_button.jpg");
			this.il.Images.SetKeyName(2, "left.bmp");
			this.il.Images.SetKeyName(3, "right.bmp");
			this.il.Images.SetKeyName(4, "up.bmp");
			this.il.Images.SetKeyName(5, "down.bmp");
			this.il.Images.SetKeyName(6, "plusx.BMP");
			this.il.Images.SetKeyName(7, "minusx.BMP");
			this.il.Images.SetKeyName(8, "plusy.BMP");
			this.il.Images.SetKeyName(9, "minusy.BMP");
			this.hScrollBar1.LargeChange = 60;
			this.hScrollBar1.Location = new System.Drawing.Point(250, 551);
			this.hScrollBar1.Name = "hScrollBar1";
			this.hScrollBar1.Size = new System.Drawing.Size(757, 16);
			this.hScrollBar1.TabIndex = 14;
			this.hScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(HScrollBar1_Scroll);
			this.pictBox1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
			this.pictBox1.BackColor = System.Drawing.SystemColors.Control;
			this.pictBox1.Location = new System.Drawing.Point(250, 40);
			this.pictBox1.MinimumSize = new System.Drawing.Size(757, 520);
			this.pictBox1.Name = "pictBox1";
			this.pictBox1.Size = new System.Drawing.Size(783, 569);
			this.pictBox1.TabIndex = 12;
			this.pictBox1.TabStop = false;
			this.pictBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(UIGraphBase_KeyDown);
			this.pictBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(pictbox_MouseDown);
			this.pictBox1.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(UIGraphBase_PreveyDown);
			this.toolStrip1.AutoSize = false;
			this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
			this.toolStrip1.GripMargin = new System.Windows.Forms.Padding(3);
			this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[29]
			{
				this.toolStripButtonLeft, this.toolStripButtonRight, this.toolStripButtonUp, this.toolStripButtonDown, this.toolStripSeparator1, this.toolStripLabel1, this.toolStripButtonPlusX, this.toolStripButtonMinusX, this.toolStripSeparator2, this.toolStripLabel2,
				this.toolStripButtonPlusY, this.toolStripButtonMinusY, this.toolStripSeparator3, this.toolStripLabel3, this.toolStripComboBoxStep, this.toolStripLabel4, this.toolStripButtonShiftLeft, this.toolStripButtonShiftRight, this.toolStripSeparator4, this.toolStripButtonStop,
				this.toolStripButtonRecord, this.toolStripButtonExport, this.toolStripLabelLiveView, this.toolStripSeparator5, this.toolStripComboBoxLeadinOut, this.toolStripButtonShowLInOut, this.toolStripSeparator7, this.toolStripButtonFileInfo, this.toolStripSeparator6
			});
			this.toolStrip1.Location = new System.Drawing.Point(1, 1);
			this.toolStrip1.Margin = new System.Windows.Forms.Padding(1);
			this.toolStrip1.Name = "toolStrip1";
			this.toolStrip1.Size = new System.Drawing.Size(1000, 25);
			this.toolStrip1.Stretch = true;
			this.toolStrip1.TabIndex = 19;
			this.toolStrip1.Text = "toolStrip1";
			this.toolStripButtonLeft.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonLeft.Image = MEA.AE_BusinessLogic.Properties.Resources._112_LeftArrowLong_Green_16x16_721;
			this.toolStripButtonLeft.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonLeft.Name = "toolStripButtonLeft";
			this.toolStripButtonLeft.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonLeft.Text = "toolStripButton1";
			this.toolStripButtonLeft.ToolTipText = "Move left";
			this.toolStripButtonLeft.Click += new System.EventHandler(GraphMoveLeft_Click);
			this.toolStripButtonRight.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonRight.Image = MEA.AE_BusinessLogic.Properties.Resources._112_RightArrowLong_Green_16x16_721;
			this.toolStripButtonRight.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonRight.Name = "toolStripButtonRight";
			this.toolStripButtonRight.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonRight.Text = "toolStripButton2";
			this.toolStripButtonRight.ToolTipText = "Move right";
			this.toolStripButtonRight.Click += new System.EventHandler(GraphMoveRight_Click);
			this.toolStripButtonUp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonUp.Image = MEA.AE_BusinessLogic.Properties.Resources._112_UpArrowShort_Green_16x16_72;
			this.toolStripButtonUp.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonUp.Name = "toolStripButtonUp";
			this.toolStripButtonUp.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonUp.Text = "toolStripButton3";
			this.toolStripButtonUp.ToolTipText = "Move up";
			this.toolStripButtonUp.Click += new System.EventHandler(GraphMoveUp_Click);
			this.toolStripButtonDown.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonDown.Image = MEA.AE_BusinessLogic.Properties.Resources._112_DownArrowShort_Green_16x16_72;
			this.toolStripButtonDown.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonDown.Name = "toolStripButtonDown";
			this.toolStripButtonDown.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonDown.Text = "toolStripButton4";
			this.toolStripButtonDown.ToolTipText = "Move down";
			this.toolStripButtonDown.Click += new System.EventHandler(GraphMoveDown_Click);
			this.toolStripSeparator1.Name = "toolStripSeparator1";
			this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
			this.toolStripLabel1.Font = new System.Drawing.Font("Tahoma", 8.25f, System.Drawing.FontStyle.Bold);
			this.toolStripLabel1.Name = "toolStripLabel1";
			this.toolStripLabel1.Size = new System.Drawing.Size(14, 22);
			this.toolStripLabel1.Text = "X";
			this.toolStripButtonPlusX.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonPlusX.Image = MEA.AE_BusinessLogic.Properties.Resources._112_Plus_Green_16x16_721;
			this.toolStripButtonPlusX.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonPlusX.Name = "toolStripButtonPlusX";
			this.toolStripButtonPlusX.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonPlusX.Text = "toolStripButton5";
			this.toolStripButtonPlusX.ToolTipText = "Zoom in X";
			this.toolStripButtonPlusX.Click += new System.EventHandler(GraphPlusX_Click);
			this.toolStripButtonMinusX.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonMinusX.Image = MEA.AE_BusinessLogic.Properties.Resources._112_Minus_Green_16x16_721;
			this.toolStripButtonMinusX.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonMinusX.Name = "toolStripButtonMinusX";
			this.toolStripButtonMinusX.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonMinusX.Text = "toolStripButton6";
			this.toolStripButtonMinusX.ToolTipText = "Zoom out X";
			this.toolStripButtonMinusX.Click += new System.EventHandler(GraphMinusX_Click);
			this.toolStripSeparator2.Name = "toolStripSeparator2";
			this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
			this.toolStripLabel2.Font = new System.Drawing.Font("Tahoma", 8.25f, System.Drawing.FontStyle.Bold);
			this.toolStripLabel2.Name = "toolStripLabel2";
			this.toolStripLabel2.Size = new System.Drawing.Size(14, 22);
			this.toolStripLabel2.Text = "Y";
			this.toolStripButtonPlusY.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonPlusY.Image = MEA.AE_BusinessLogic.Properties.Resources._112_Plus_Green_16x16_721;
			this.toolStripButtonPlusY.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonPlusY.Name = "toolStripButtonPlusY";
			this.toolStripButtonPlusY.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonPlusY.Text = "toolStripButton7";
			this.toolStripButtonPlusY.ToolTipText = "Zoom in Y";
			this.toolStripButtonPlusY.Click += new System.EventHandler(GraphPlusY_Click);
			this.toolStripButtonMinusY.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonMinusY.Image = MEA.AE_BusinessLogic.Properties.Resources._112_Minus_Green_16x16_721;
			this.toolStripButtonMinusY.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonMinusY.Name = "toolStripButtonMinusY";
			this.toolStripButtonMinusY.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonMinusY.Text = "toolStripButton8";
			this.toolStripButtonMinusY.ToolTipText = "Zoom out Y";
			this.toolStripButtonMinusY.Click += new System.EventHandler(GraphMinusY_Click);
			this.toolStripSeparator3.Name = "toolStripSeparator3";
			this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25);
			this.toolStripLabel3.Font = new System.Drawing.Font("Tahoma", 8.25f, System.Drawing.FontStyle.Bold);
			this.toolStripLabel3.Margin = new System.Windows.Forms.Padding(10, 1, 0, 2);
			this.toolStripLabel3.Name = "toolStripLabel3";
			this.toolStripLabel3.Size = new System.Drawing.Size(84, 22);
			this.toolStripLabel3.Text = "Shift ECU B by";
			this.toolStripComboBoxStep.AutoSize = false;
			this.toolStripComboBoxStep.Items.AddRange(new object[4] { "1", "10", "50", "100" });
			this.toolStripComboBoxStep.Name = "toolStripComboBoxStep";
			this.toolStripComboBoxStep.Size = new System.Drawing.Size(40, 23);
			this.toolStripLabel4.Name = "toolStripLabel4";
			this.toolStripLabel4.Size = new System.Drawing.Size(20, 22);
			this.toolStripLabel4.Text = "[s]";
			this.toolStripButtonShiftLeft.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonShiftLeft.Image = MEA.AE_BusinessLogic.Properties.Resources._112_LeftArrowLong_Green_16x16_721;
			this.toolStripButtonShiftLeft.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonShiftLeft.Name = "toolStripButtonShiftLeft";
			this.toolStripButtonShiftLeft.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonShiftLeft.Text = "toolStripButton2";
			this.toolStripButtonShiftLeft.ToolTipText = "Shift B: Side left";
			this.toolStripButtonShiftLeft.Click += new System.EventHandler(buttonGraphMoveLeft_Click);
			this.toolStripButtonShiftRight.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonShiftRight.Image = MEA.AE_BusinessLogic.Properties.Resources._112_RightArrowLong_Green_16x16_721;
			this.toolStripButtonShiftRight.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonShiftRight.Name = "toolStripButtonShiftRight";
			this.toolStripButtonShiftRight.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonShiftRight.Text = "toolStripButton1";
			this.toolStripButtonShiftRight.ToolTipText = "Shift B: Side right";
			this.toolStripButtonShiftRight.Click += new System.EventHandler(buttonGraphMoveRight_Click);
			this.toolStripSeparator4.Name = "toolStripSeparator4";
			this.toolStripSeparator4.Size = new System.Drawing.Size(6, 25);
			this.toolStripButtonStop.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
			this.toolStripButtonStop.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonStop.Image = MEA.AE_BusinessLogic.Properties.Resources.stop_button;
			this.toolStripButtonStop.ImageTransparentColor = System.Drawing.Color.Lavender;
			this.toolStripButtonStop.Name = "toolStripButtonStop";
			this.toolStripButtonStop.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonStop.Text = "Stop recording...";
			this.toolStripButtonRecord.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
			this.toolStripButtonRecord.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonRecord.Image = MEA.AE_BusinessLogic.Properties.Resources.record;
			this.toolStripButtonRecord.ImageTransparentColor = System.Drawing.Color.Lavender;
			this.toolStripButtonRecord.Name = "toolStripButtonRecord";
			this.toolStripButtonRecord.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonRecord.Text = "Start recording...";
			this.toolStripButtonExport.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
			this.toolStripButtonExport.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonExport.Image = MEA.AE_BusinessLogic.Properties.Resources.export;
			this.toolStripButtonExport.ImageTransparentColor = System.Drawing.Color.GhostWhite;
			this.toolStripButtonExport.Name = "toolStripButtonExport";
			this.toolStripButtonExport.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonExport.Text = "toolStripButton11";
			this.toolStripButtonExport.ToolTipText = "Export data in INCA format";
			this.toolStripButtonExport.Visible = false;
			this.toolStripLabelLiveView.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
			this.toolStripLabelLiveView.Font = new System.Drawing.Font("Tahoma", 8.25f, System.Drawing.FontStyle.Bold);
			this.toolStripLabelLiveView.Margin = new System.Windows.Forms.Padding(10, 1, 0, 2);
			this.toolStripLabelLiveView.Name = "toolStripLabelLiveView";
			this.toolStripLabelLiveView.Size = new System.Drawing.Size(56, 22);
			this.toolStripLabelLiveView.Text = "LiveView";
			this.toolStripSeparator5.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
			this.toolStripSeparator5.Name = "toolStripSeparator5";
			this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25);
			this.toolStripComboBoxLeadinOut.Enabled = false;
			this.toolStripComboBoxLeadinOut.Font = new System.Drawing.Font("Segoe UI", 9f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
			this.toolStripComboBoxLeadinOut.Name = "toolStripComboBoxLeadinOut";
			this.toolStripComboBoxLeadinOut.Size = new System.Drawing.Size(300, 25);
			this.toolStripComboBoxLeadinOut.ToolTipText = "Select LeadIn-Out Time";
			this.toolStripComboBoxLeadinOut.Visible = false;
			this.toolStripComboBoxLeadinOut.SelectedIndexChanged += new System.EventHandler(ev_GoToLeadInOutPos);
			this.toolStripButtonShowLInOut.BackColor = System.Drawing.SystemColors.Control;
			this.toolStripButtonShowLInOut.CheckOnClick = true;
			this.toolStripButtonShowLInOut.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonShowLInOut.Image = (System.Drawing.Image)resources.GetObject("toolStripButtonShowLInOut.Image");
			this.toolStripButtonShowLInOut.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonShowLInOut.Name = "toolStripButtonShowLInOut";
			this.toolStripButtonShowLInOut.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonShowLInOut.Text = "toolStripButtonShowLInOut";
			this.toolStripButtonShowLInOut.ToolTipText = "Show or hide LeadIn and LeadOut Times";
			this.toolStripButtonShowLInOut.Visible = false;
			this.toolStripButtonShowLInOut.Click += new System.EventHandler(ButtonShowLInOutClick);
			this.toolStripSeparator7.Name = "toolStripSeparator7";
			this.toolStripSeparator7.Size = new System.Drawing.Size(6, 25);
			this.toolStripSeparator7.Visible = false;
			this.toolStripButtonFileInfo.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButtonFileInfo.Image = MEA.AE_BusinessLogic.Properties.Resources.document_properties;
			this.toolStripButtonFileInfo.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButtonFileInfo.Name = "toolStripButtonFileInfo";
			this.toolStripButtonFileInfo.Size = new System.Drawing.Size(23, 22);
			this.toolStripButtonFileInfo.Text = "toolStripButtonFileInfo";
			this.toolStripButtonFileInfo.ToolTipText = "Shows infos about Log-File";
			this.toolStripButtonFileInfo.Click += new System.EventHandler(toolStripButtonFileInfo_Click);
			this.toolStripSeparator6.Name = "toolStripSeparator6";
			this.toolStripSeparator6.Size = new System.Drawing.Size(6, 25);
			this.checkedDataGridViewGraphSignals.Location = new System.Drawing.Point(0, 40);
			this.checkedDataGridViewGraphSignals.Name = "checkedDataGridViewGraphSignals";
			this.checkedDataGridViewGraphSignals.Size = new System.Drawing.Size(240, 150);
			this.checkedDataGridViewGraphSignals.TabIndex = 0;
			this.dataGridViewSignalCheckBoxCol.Name = "dataGridViewSignalCheckBoxCol";
			this.dataGridViewSignalNameCol.Name = "dataGridViewSignalNameCol";
			this.dataGridViewSignalValueCol.Name = "dataGridViewSignalValueCol";
			base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.AutoSize = true;
			base.Controls.Add(this.toolStrip1);
			base.Controls.Add(this.checkedDataGridViewGraphSignals);
			base.Controls.Add(this.hScrollBar1);
			base.Controls.Add(this.pictBox1);
			base.Location = new System.Drawing.Point(0, 8);
			this.MinimumSize = new System.Drawing.Size(1040, 617);
			base.Name = "UIGraphBase";
			base.Size = new System.Drawing.Size(1040, 617);
			base.Tag = "";
			((System.ComponentModel.ISupportInitialize)this.pictBox1).EndInit();
			this.toolStrip1.ResumeLayout(false);
			this.toolStrip1.PerformLayout();
			((System.ComponentModel.ISupportInitialize)this.checkedDataGridViewGraphSignals).EndInit();
			base.ResumeLayout(false);
		}

		public new void Move(float x, float y)
		{
			foreach (Koordsyst koordsyst in koordsysts)
			{
				koordsyst.offsetWert(x, y);
			}
			RedrawAll(true);
		}

		protected void pictbox_MouseDown(object sender, MouseEventArgs e)
		{
			object obj = new object();
			myDataPos = -1;
			obj = graph.getClickObj(new PointF(e.X, e.Y), ref myDataPos);
			if (obj != null)
			{
				if (e.Button == MouseButtons.Left)
				{
					if (obj is Function)
					{
						lock (obj)
						{
							selectedfunct = (Function)obj;
							selectedpoint = selectedfunct.selected_point;
							lock (selectedfunct)
							{
								try
								{
									DateTime ptTimestamp;
									if (myDataPos > -1)
									{
										ptTimestamp = (DateTime)selectedfunct.timestamps[myDataPos];
										if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphLiveViewRec)
										{
											SetCoursorPosVals();
										}
										else if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphDataLog)
										{
											SetCoursorPosVals(selectedfunct.AB);
											if (activeECU != selectedfunct.AB)
											{
												activeECU = selectedfunct.AB;
												showLeadInOut();
											}
										}
									}
									else
									{
										ptTimestamp = (DateTime)selectedfunct.timestamps[selectedfunct.points.IndexOf(selectedpoint)];
									}
									selectedfunct.PtTimestamp = ptTimestamp;
								}
								catch
								{
								}
							}
						}
					}
					if (propgrid != null)
					{
						propgrid.SelectedObject = obj;
					}
				}
				RedrawAll(true);
			}
			if (!pictBox1.Focus())
			{
				pictBox1.Focus();
			}
		}

		protected void pictbox_MouseWheel(object sender, MouseEventArgs e)
		{
			if (e.Delta < 0)
			{
				graph.g.RenderingOrigin = new Point(200, 200);
			}
			RedrawAll(true);
		}

		public void RedrawAll(bool axesChanged)
		{
			TH_Redraw(axesChanged);
		}

		private void ButtonShowLInOutClick(object sender, EventArgs e)
		{
			if (SetSessionMarker)
			{
				SetSessionMarker = false;
			}
			else
			{
				SetSessionMarker = true;
			}
			RedrawAll(true);
		}

		private void TH_Redraw(object RedrawRun)
		{
			try
			{
				bool flag = true;
				while (flag)
				{
					lock (graph)
					{
						if ((bool)RedrawRun)
						{
							graph.g.Clear(BgColor);
						}
						lock (koordsysts.SyncRoot)
						{
							foreach (Koordsyst koordsyst in koordsysts)
							{
								try
								{
									lock (graph.g)
									{
										koordsyst.Draw(ref graph.g);
									}
								}
								catch (Exception)
								{
								}
							}
						}
						bool sessionMarkerWritten = SetSessionMarker;
						ConfigData.e_ECUS e_ECUS = ConfigData.e_ECUS.NO_ECU;
						lock (functs.SyncRoot)
						{
							foreach (Function funct in functs)
							{
								if (funct.AB == ConfigData.e_ECUS.ECU_A && e_ECUS != ConfigData.e_ECUS.ECU_A)
								{
									sessionMarkerWritten = SetSessionMarker;
									e_ECUS = ConfigData.e_ECUS.ECU_A;
								}
								else if (funct.AB == ConfigData.e_ECUS.ECU_B && e_ECUS != ConfigData.e_ECUS.ECU_B)
								{
									sessionMarkerWritten = SetSessionMarker;
									e_ECUS = ConfigData.e_ECUS.ECU_B;
								}
								try
								{
									funct.SessionMarkerWritten = sessionMarkerWritten;
									funct.Draw(ref graph.g, true);
									sessionMarkerWritten = funct.SessionMarkerWritten;
								}
								catch (Exception arg)
								{
									Console.WriteLine("ERR: {0}", arg);
								}
							}
						}
						if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphLiveViewRec)
						{
							try
							{
								if (CaCrDisplayA != null)
								{
									Koordsyst koo = (Koordsyst)koordsysts[CaCrDisplayA.fnChkTestPos];
									Function function2 = (Function)functs[CaCrDisplayA.fnChkTestPos];
									if (function2.Visible)
									{
										CaCrDisplayA.Draw(ref graph.g, ref koo);
									}
								}
								if (CaCrDisplayB != null && CaCrDisplayB.PosOfCaCrDispf.Count > 0)
								{
									Koordsyst koo2 = (Koordsyst)koordsysts[CaCrDisplayB.fnChkTestPos];
									Function function3 = (Function)functs[CaCrDisplayB.fnChkTestPos];
									if (function3.Visible)
									{
										CaCrDisplayB.Draw(ref graph.g, ref koo2);
									}
								}
							}
							catch (Exception arg2)
							{
								Console.WriteLine("ERR: {0}", arg2);
							}
						}
						else if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphLiveView)
						{
							try
							{
								if (CaCrDisplayA != null && CaCrDisplayA.PosOfCaCrDispfLiveView.Count > 0)
								{
									Koordsyst koo3 = (Koordsyst)koordsysts[CaCrDisplayA.fnChkTestPos];
									Function function4 = (Function)functs[CaCrDisplayA.fnChkTestPos];
									if (function4.Visible)
									{
										CaCrDisplayA.Draw(ref graph.g, ref koo3);
									}
								}
								if (CaCrDisplayB != null && CaCrDisplayB.PosOfCaCrDispfLiveView.Count > 0)
								{
									Koordsyst koo4 = (Koordsyst)koordsysts[CaCrDisplayB.fnChkTestPos];
									Function function5 = (Function)functs[CaCrDisplayB.fnChkTestPos];
									if (function5.Visible)
									{
										CaCrDisplayB.Draw(ref graph.g, ref koo4);
									}
								}
							}
							catch (Exception arg3)
							{
								Console.WriteLine("ERR: {0}", arg3);
							}
						}
						pictBox1.Invalidate();
					}
					flag = false;
				}
			}
			catch (Exception)
			{
			}
		}

		public void Removevar(Var var, Var koordvar)
		{
			lock (GraphVars.SyncRoot)
			{
				lock (functs.SyncRoot)
				{
					lock (koordsysts.SyncRoot)
					{
						GraphVars.Remove(var);
						GraphVars_hash.Remove(var.Titel);
						Function function = (Function)functs_hash[var.Name];
						if (selectedfunct == function)
						{
							selectedfunct = null;
						}
						functs_hash.Remove(var.Name);
						graph.RemoveFunction(function);
						functs.Remove(function);
						if (koordvar == null)
						{
							bool flag = true;
							for (int i = 0; i < functs.Count; i++)
							{
								if (((Function)functs[i]).koordsyst == function.koordsyst)
								{
									flag = false;
									break;
								}
							}
							if (flag)
							{
								koordsysts.Remove(function.koordsyst);
								function.koordsyst = null;
							}
							function = null;
						}
						else
						{
							Koordsyst koordsyst = null;
							for (int j = 0; j < koordsysts.Count; j++)
							{
								if (((Koordsyst)koordsysts[j]).koordvar == koordvar)
								{
									koordsyst = (Koordsyst)koordsysts[j];
									break;
								}
							}
							if (koordsyst == null)
							{
								return;
							}
							bool flag2 = true;
							for (int k = 0; k < functs.Count; k++)
							{
								if (((Function)functs[k]).koordsyst == koordsyst)
								{
									flag2 = false;
									break;
								}
							}
							if (flag2)
							{
								koordsysts.Remove(koordsyst);
								koordsyst = null;
							}
						}
						for (int l = 0; l < koordsysts.Count; l++)
						{
							((Koordsyst)koordsysts[l]).Offset = new PointF(koordsysts.Count * 30, 25f);
							((Koordsyst)koordsysts[l]).YAxeOffset = (koordsysts.Count - l) * 30;
						}
						if (koordsysts.Count > 0)
						{
							((Koordsyst)koordsysts[0]).XAxe = true;
						}
					}
				}
			}
			RedrawAll(true);
		}

		public void ResizeUiGraph1(object sender, EventArgs e)
		{
			base.SizeChanged -= ResizeUiGraph1;
			Size size;
			if (sender is UIGraphWindow)
			{
				UIGraphWindow uIGraphWindow = (UIGraphWindow)sender;
				size = uIGraphWindow.Size;
			}
			else if (sender is UIGraphDatLog)
			{
				UIGraphDatLog uIGraphDatLog = (UIGraphDatLog)sender;
				size = uIGraphDatLog.Size;
			}
			else
			{
				UIGraphLiveView uIGraphLiveView = (UIGraphLiveView)sender;
				size = uIGraphLiveView.Size;
			}
			if (size.Width >= 1040 && size.Height >= 617)
			{
				Size size2 = checkedDataGridViewGraphSignals.Size;
				Size size3 = hScrollBar1.Size;
				Size size4 = pictBox1.Size;
				Size size5 = toolStrip1.Size;
				Point location = hScrollBar1.Location;
				Point location2 = pictBox1.Location;
				if (size.Width < 1100)
				{
					size2.Width = 240;
				}
				else
				{
					size2.Width = 288;
				}
				size2.Height = size.Height - 89;
				checkedDataGridViewGraphSignals.Size = size2;
				location2.X = size2.Width + 10;
				pictBox1.Location = location2;
				if (pictBox1.MinimumSize.Width >= size.Width - size2.Width - 43)
				{
					size4.Width = pictBox1.MinimumSize.Width;
				}
				else
				{
					size4.Width = size.Width - size2.Width - 43;
				}
				size4.Height = size.Height - 98;
				location.Y = size.Height - 67;
				location.X = location2.X;
				hScrollBar1.Location = location;
				size3.Width = size4.Width;
				hScrollBar1.Size = size3;
				size5.Width = size.Width - 26;
				toolStrip1.Size = size5;
				ResizeGraph(size4);
				Thread.Sleep(20);
				base.SizeChanged += ResizeUiGraph1;
			}
		}

		public void ResizeGraph(Size s)
		{
			if (s.Width < 0 || s.Height < 0)
			{
				return;
			}
			graph.Resize(s.Width, s.Height);
			pictBox1.Size = s;
			pictBox1.Image = graph.bmp;
			foreach (Koordsyst koordsyst in koordsysts)
			{
				koordsyst.BILD_HEIGHT = s.Height;
				koordsyst.BILD_WIDTH = s.Width;
			}
			RedrawAll(true);
		}

		protected abstract void setScrollbarRange();

		private void GraphMoveLeft_Click(object sender, EventArgs e)
		{
			lock (koordsysts.SyncRoot)
			{
				Koordsyst koordsyst = (Koordsyst)koordsysts[0];
				float num = koordsyst.XLen / 10f;
				if (koordsyst.XMin - num < (float)hScrollBar1.Minimum - num)
				{
					return;
				}
				foreach (Koordsyst koordsyst2 in koordsysts)
				{
					koordsyst2.offsetWert(0f - num, 0f);
				}
				int num2 = hScrollBar1.Value - (int)num;
				if (num2 < hScrollBar1.Minimum)
				{
					hScrollBar1.Value = hScrollBar1.Minimum;
				}
				else
				{
					hScrollBar1.Value = num2;
				}
			}
			RedrawAll(true);
		}

		private void GraphMoveRight_Click(object sender, EventArgs e)
		{
			lock (koordsysts.SyncRoot)
			{
				Koordsyst koordsyst = (Koordsyst)koordsysts[0];
				float num = koordsyst.XLen / 10f;
				if (koordsyst.XMax + num > (float)hScrollBar1.Maximum + num)
				{
					return;
				}
				foreach (Koordsyst koordsyst2 in koordsysts)
				{
					koordsyst2.offsetWert(num, 0f);
				}
				int num2 = hScrollBar1.Value + (int)num;
				if (num2 > hScrollBar1.Maximum)
				{
					hScrollBar1.Value = hScrollBar1.Maximum;
				}
				else
				{
					hScrollBar1.Value = num2;
				}
			}
			RedrawAll(true);
		}

		private void GraphMoveUp_Click(object sender, EventArgs e)
		{
			lock (koordsysts.SyncRoot)
			{
				foreach (Koordsyst koordsyst in koordsysts)
				{
					koordsyst.offsetWert(0f, koordsyst.YLen / 10f);
				}
			}
			RedrawAll(true);
		}

		private void GraphMoveDown_Click(object sender, EventArgs e)
		{
			lock (koordsysts.SyncRoot)
			{
				foreach (Koordsyst koordsyst in koordsysts)
				{
					koordsyst.offsetWert(0f, (0f - koordsyst.YLen) / 10f);
				}
			}
			RedrawAll(true);
		}

		private void GraphMinusX_Click(object sender, EventArgs e)
		{
			try
			{
				foreach (Koordsyst koordsyst in koordsysts)
				{
					lock (koordsyst)
					{
						if (xmin < 0)
						{
							if (koordsyst.XMax + koordsyst.XLen / 10f < 0f)
							{
								koordsyst.XMax += koordsyst.XLen / 10f;
								continue;
							}
							koordsyst.XMax = 0f;
							koordsyst.XMin -= koordsyst.XLen / 10f;
						}
						else if (koordsyst.XMin - koordsyst.XLen / 10f < 0f)
						{
							koordsyst.XMin = 0f;
							koordsyst.XMax += koordsyst.XLen / 10f;
						}
						else
						{
							koordsyst.XMax += koordsyst.XLen / 10f;
							koordsyst.XMin -= koordsyst.XLen / 10f;
						}
					}
				}
				int num = hScrollBar1.Maximum - hScrollBar1.Minimum;
				if (xmin < 0)
				{
					hScrollBar1.Minimum = xmin;
				}
				else
				{
					hScrollBar1.Maximum -= num / 10;
				}
			}
			catch
			{
			}
			RedrawAll(true);
		}

		private void GraphPlusX_Click(object sender, EventArgs e)
		{
			try
			{
				int num = hScrollBar1.Maximum - hScrollBar1.Minimum;
				foreach (Koordsyst koordsyst in koordsysts)
				{
					lock (koordsyst)
					{
						if (xmin < 0)
						{
							koordsyst.XMin += koordsyst.XLen / 10f;
						}
						else
						{
							koordsyst.XMax -= koordsyst.XLen / 10f;
						}
					}
				}
				if (xmin < 0)
				{
					hScrollBar1.Minimum = xmin;
				}
				else
				{
					hScrollBar1.Maximum += num / 10;
				}
			}
			catch
			{
			}
			RedrawAll(true);
		}

		private void GraphPlusY_Click(object sender, EventArgs e)
		{
			try
			{
				lock (koordsysts.SyncRoot)
				{
					foreach (Koordsyst koordsyst in koordsysts)
					{
						koordsyst.YMax -= koordsyst.YLen / 10f;
					}
				}
			}
			catch
			{
			}
			RedrawAll(true);
		}

		private void GraphMinusY_Click(object sender, EventArgs e)
		{
			try
			{
				lock (koordsysts.SyncRoot)
				{
					foreach (Koordsyst koordsyst in koordsysts)
					{
						koordsyst.YMax += koordsyst.YLen / 10f;
					}
				}
			}
			catch
			{
			}
			RedrawAll(true);
		}

		public abstract void UpdateData(object sender, EventArgs e);

		public void Zoom(float factor)
		{
			lock (koordsysts.SyncRoot)
			{
				foreach (Koordsyst koordsyst in koordsysts)
				{
					koordsyst.zoom(factor);
				}
			}
			RedrawAll(true);
		}

		public UIGraphBase(ServiceLayer serviceLayer, ConfigBase.EGraphicAspect graphicaspect)
		{
			graphicAspect = graphicaspect;
			InitializeComponent();
			this.serviceLayer = serviceLayer;
			tend = 100f;
			dataupdatetime = 100;
			SuspendLayout();
			SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
			UpdateStyles();
			graph = new Graph(pictBox1.Width, pictBox1.Height);
			graph.BgColor = Color.LightBlue;
			graph.Aliasing = SmoothingMode.HighQuality;
			pictBox1.Image = graph.bmp;
			ResumeLayout(false);
			functs = new ArrayList();
			koordsysts = new ArrayList();
			functs = ArrayList.Synchronized(functs);
			koordsysts = ArrayList.Synchronized(koordsysts);
			functs_hash = new Hashtable(80);
			startstopmode = StartStopMode.tozero;
			cursorx = true;
			cursory = false;
			triggersingle = false;
			toolStripComboBoxStep.SelectedIndex = 0;
			hScrollBar1.Minimum = 0;
			hScrollBar1.SmallChange = pictBox1.Width / 20;
			hScrollBar1.LargeChange = pictBox1.Width / 10;
			ResizeUiGraph1(this, null);
			base.Resize += ResizeUiGraph1;
			base.Size = new Size(1081, 638);
			ResizeUiGraph1(this, null);
		}

		public UIGraphBase(ConfigBase.EGraphicAspect graphicaspect)
		{
			graphicAspect = graphicaspect;
			InitializeComponent();
			tend = 100f;
			dataupdatetime = 100;
			SuspendLayout();
			SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
			UpdateStyles();
			graph = new Graph(pictBox1.Width, pictBox1.Height);
			graph.BgColor = Color.LightBlue;
			graph.Aliasing = SmoothingMode.HighQuality;
			pictBox1.Image = graph.bmp;
			ResumeLayout(false);
			functs = new ArrayList();
			koordsysts = new ArrayList();
			functs = ArrayList.Synchronized(functs);
			koordsysts = ArrayList.Synchronized(koordsysts);
			functs_hash = new Hashtable(80);
			startstopmode = StartStopMode.tozero;
			cursorx = true;
			cursory = false;
			triggersingle = false;
			toolStripComboBoxStep.SelectedIndex = 0;
			hScrollBar1.Minimum = 0;
			hScrollBar1.SmallChange = pictBox1.Width / 20;
			hScrollBar1.LargeChange = pictBox1.Width / 10;
		}

		protected void initCheckedDataGridViewGraphSignals()
		{
			new ComponentResourceManager(typeof(UIGraphBase));
			checkedDataGridViewGraphSignals.AllowUserToDeleteRows = false;
			checkedDataGridViewGraphSignals.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			checkedDataGridViewGraphSignals.Location = new Point(4, 40);
			checkedDataGridViewGraphSignals.Name = "checkedDataGridViewGraphSignals";
			checkedDataGridViewGraphSignals.RowHeadersVisible = false;
			checkedDataGridViewGraphSignals.TabIndex = 20;
			checkedDataGridViewGraphSignals.CellMouseClick += checkedDataGridViewGraphSignals_CellContentClick;
			checkedDataGridViewGraphSignals.CellClick += checkedDataGridViewGraphSignals_CellEventHandler;
			dataGridViewSignalCheckBoxCol.FalseValue = "false";
			dataGridViewSignalCheckBoxCol.HeaderText = "Column1";
			dataGridViewSignalCheckBoxCol.Name = "dataGridViewSignalCheckBoxCol";
			dataGridViewSignalCheckBoxCol.TrueValue = "true";
			dataGridViewSignalCheckBoxCol.HeaderText = " ";
			dataGridViewSignalCheckBoxCol.Name = "dataGridViewSignalCheckBox";
			dataGridViewSignalCheckBoxCol.Resizable = DataGridViewTriState.False;
			dataGridViewSignalCheckBoxCol.Width = 22;
			dataGridViewSignalCheckBoxCol.TrueValue = "true";
			dataGridViewSignalCheckBoxCol.FalseValue = "false";
			dataGridViewSignalNameCol.HeaderText = "Column1";
			dataGridViewSignalNameCol.Name = "dataGridViewSignalNameCol";
			dataGridViewSignalNameCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			dataGridViewSignalNameCol.Frozen = false;
			dataGridViewSignalNameCol.MinimumWidth = 144;
			dataGridViewSignalNameCol.Name = "dataGridViewSignalNameCol";
			dataGridViewSignalNameCol.ReadOnly = true;
			dataGridViewSignalNameCol.Resizable = DataGridViewTriState.True;
			dataGridViewSignalNameCol.SortMode = DataGridViewColumnSortMode.Automatic;
			dataGridViewSignalNameCol.HeaderText = "ECU:Signal Name";
			dataGridViewSignalNameCol.CellTemplate = new DataGridViewTextBoxCell();
			dataGridViewSignalValueCol.HeaderText = "Column2";
			dataGridViewSignalValueCol.Name = "dataGridViewSignalValueCol";
			dataGridViewSignalValueCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			dataGridViewSignalValueCol.Frozen = false;
			dataGridViewSignalValueCol.Name = "dataGridViewSignalName";
			dataGridViewSignalValueCol.HeaderText = "Value";
			dataGridViewSignalValueCol.ReadOnly = true;
			dataGridViewSignalValueCol.Resizable = DataGridViewTriState.False;
			dataGridViewSignalValueCol.SortMode = DataGridViewColumnSortMode.Automatic;
			dataGridViewSignalValueCol.CellTemplate = new DataGridViewTextBoxCell();
			dataGridViewSignalValueCol.MinimumWidth = 64;
			checkedDataGridViewGraphSignals.AllowUserToAddRows = false;
			checkedDataGridViewGraphSignals.AllowUserToDeleteRows = false;
			checkedDataGridViewGraphSignals.AllowUserToResizeRows = false;
			checkedDataGridViewGraphSignals.BackgroundColor = SystemColors.Window;
			checkedDataGridViewGraphSignals.BorderStyle = BorderStyle.Fixed3D;
			checkedDataGridViewGraphSignals.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			checkedDataGridViewGraphSignals.RowTemplate.Height = 18;
			checkedDataGridViewGraphSignals.ColumnHeadersVisible = true;
			checkedDataGridViewGraphSignals.Columns.AddRange(dataGridViewSignalCheckBoxCol, dataGridViewSignalNameCol, dataGridViewSignalValueCol);
			dataGridViewSignalNameCol.MinimumWidth = 160;
			checkedDataGridViewGraphSignals.ColumnCount = 3;
			checkedDataGridViewGraphSignals.GridColor = SystemColors.ActiveBorder;
			checkedDataGridViewGraphSignals.Location = new Point(4, 40);
			checkedDataGridViewGraphSignals.MultiSelect = false;
			checkedDataGridViewGraphSignals.Size = new Size(240, 528);
			checkedDataGridViewGraphSignals.VirtualMode = false;
			checkedDataGridViewGraphSignals.Rows.Add();
			checkedDataGridViewGraphSignals.Rows[0].Cells[0].Value = true;
			int rowCount = checkedDataGridViewGraphSignals.RowCount;
			checkedSigIx = new List<CheckedSigVals>();
			if (!pictBox1.Focus())
			{
				pictBox1.Focus();
			}
		}

		public void listViewCurrentValueEnabled(bool enable)
		{
			if (!CaCrTested)
			{
				if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphLiveViewRec)
				{
					int num = -1;
					int num2 = -1;
					int num3 = -1;
					int num4 = -1;
					for (int i = 0; i < functs.Count; i++)
					{
						Function function = (Function)functs[i];
						if (function.Ecu_Emessage == ConfigLiveView.ESignals.e_CAN_Prpl_nPrpl)
						{
							if (function.AB == ConfigData.e_ECUS.ECU_A)
							{
								num = i;
							}
							else
							{
								num2 = i;
							}
						}
						if (function.Ecu_Emessage == ConfigLiveView.ESignals.e_CaSCrS_phiDiff)
						{
							if (function.AB == ConfigData.e_ECUS.ECU_A)
							{
								num3 = i;
							}
							else
							{
								num4 = i;
							}
						}
					}
					if (num >= 0 && num3 >= 0)
					{
						Function function2 = (Function)functs[num];
						Function function = (Function)functs[num3];
						CaCrDisplayA = new CaCrDisplay(ref function.points, ref function2.points, num3, ConfigData.e_ECUID.A);
					}
					if (num2 >= 0 && num4 >= 0)
					{
						Function function2 = (Function)functs[num2];
						Function function = (Function)functs[num4];
						CaCrDisplayB = new CaCrDisplay(ref function.points, ref function2.points, num4, ConfigData.e_ECUID.B);
					}
				}
				else if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphLiveView)
				{
					int num5 = -1;
					int num6 = -1;
					int num7 = -1;
					int num8 = -1;
					for (int j = 0; j < functs.Count; j++)
					{
						Function function3 = (Function)functs[j];
						if (CaCrDisplayA == null && function3.Ecu_Emessage == ConfigLiveView.ESignals.e_CAN_Prpl_nPrpl)
						{
							if (function3.AB == ConfigData.e_ECUS.ECU_A)
							{
								num5 = j;
							}
							else
							{
								num6 = j;
							}
						}
						if (CaCrDisplayB == null && function3.Ecu_Emessage == ConfigLiveView.ESignals.e_CaSCrS_phiDiff)
						{
							if (function3.AB == ConfigData.e_ECUS.ECU_A)
							{
								num7 = j;
							}
							else
							{
								num8 = j;
							}
						}
					}
					if (num5 >= 0 && num7 >= 0)
					{
						CaCrDisplayA = new CaCrDisplay(num7, num5, dataupdatetime, ConfigData.e_ECUID.A);
					}
					if (num6 >= 0 && num8 >= 0)
					{
						CaCrDisplayB = new CaCrDisplay(num8, num6, dataupdatetime, ConfigData.e_ECUID.B);
					}
				}
			}
			CheckedListBoxSignalsItemCheck(0);
		}

		private void UIGraphBase_PreveyDown(object sender, PreviewKeyDownEventArgs e)
		{
			pictBox1.PreviewKeyDown -= UIGraphBase_PreveyDown;
			switch (e.KeyCode)
			{
			case Keys.Left:
			case Keys.Right:
				e.IsInputKey = true;
				if (!pictBox1.Focus())
				{
					pictBox1.Focus();
				}
				break;
			case Keys.Up:
			case Keys.Down:
				e.IsInputKey = true;
				if (!checkedDataGridViewGraphSignals.Focus())
				{
					checkedDataGridViewGraphSignals.Focus();
				}
				break;
			}
			pictBox1.PreviewKeyDown += UIGraphBase_PreveyDown;
		}

		public void UIGraphBase_KeyDown(object sender, KeyEventArgs e)
		{
			pictBox1.KeyDown -= UIGraphBase_KeyDown;
			e.Handled = true;
			try
			{
				object obj = new object();
				if (e.KeyCode == Keys.Left)
				{
					obj = graph.MoveSelection(true, ref myDataPos, graphicAspect);
				}
				else
				{
					if (e.KeyCode != Keys.Right)
					{
						pictBox1.KeyDown += UIGraphBase_KeyDown;
						return;
					}
					obj = graph.MoveSelection(false, ref myDataPos, graphicAspect);
				}
				if (obj is Function && myDataPos >= 0)
				{
					lock (obj)
					{
						selectedfunct = (Function)obj;
						selectedpoint = selectedfunct.selected_point;
						int index = functs.IndexOf(selectedfunct);
						Var var = (Var)GraphVars[index];
						lock (var)
						{
							if (graphicAspect != ConfigBase.EGraphicAspect.eShowGraphLiveViewRec)
							{
								myDataPos = var.data.IndexOf(selectedpoint);
							}
							if (selectedfunct.timestamps.Count > myDataPos)
							{
								DateTime ptTimestamp = (DateTime)selectedfunct.timestamps[myDataPos];
								selectedfunct.PtTimestamp = ptTimestamp;
							}
						}
						if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphLiveViewRec)
						{
							SetCoursorPosVals();
						}
						else if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphDataLog)
						{
							SetCoursorPosVals(selectedfunct.AB);
						}
					}
				}
				if (obj == null)
				{
					obj = this;
				}
				if (propgrid != null)
				{
					propgrid.SelectedObject = obj;
				}
				RedrawAll(true);
			}
			catch (ArgumentException arg)
			{
				Console.WriteLine("Write signals val Error:", arg);
			}
			pictBox1.KeyDown += UIGraphBase_KeyDown;
		}

		private void SetCoursorPosVals()
		{
			string empty = string.Empty;
			for (int i = 0; i < GraphVars.Count; i++)
			{
				Var var = (Var)GraphVars[i];
				CheckedSigVals value = checkedSigIx[i];
				switch (var.Format)
				{
				case ConfigBase.EStringFormat.e_X1:
				case ConfigBase.EStringFormat.e_X2:
				case ConfigBase.EStringFormat.e_X4:
				case ConfigBase.EStringFormat.e_X8:
				case ConfigBase.EStringFormat.e_Bin:
					empty = string.Format(ConfigBase.StrStringFormat[(uint)var.Format], (uint)var.data[myDataPos].Y);
					value.sigVal = string.Format("{0} {1}", empty, ConfigLiveView.SigClass[(int)var.SigClass].Unit);
					break;
				case ConfigBase.EStringFormat.e_F0:
				case ConfigBase.EStringFormat.e_F1:
				case ConfigBase.EStringFormat.e_F2:
				case ConfigBase.EStringFormat.e_F3:
					empty = string.Format(ConfigBase.StrStringFormat[(uint)var.Format], var.data[myDataPos].Y);
					value.sigVal = string.Format("{0} {1}", empty, ConfigLiveView.SigClass[(int)var.SigClass].Unit);
					break;
				default:
					value.sigVal = string.Empty;
					break;
				}
				checkedSigIx[i] = value;
			}
			checkedDataGridViewGraphSignals.Invoke((MethodInvoker)delegate
			{
				for (int j = 0; j < checkedSigIx.Count; j++)
				{
					checkedDataGridViewGraphSignals.Rows[j].Cells[2].Value = checkedSigIx[j].sigVal;
				}
			});
		}

		private void SetCoursorPosVals(ConfigData.e_ECUS ab)
		{
			string empty = string.Empty;
			int num;
			int num2;
			if (GraphVars.Count <= 16)
			{
				num = 0;
				num2 = GraphVars.Count;
			}
			else if (ab == ConfigData.e_ECUS.ECU_A)
			{
				num = 0;
				num2 = 16;
			}
			else
			{
				num = 16;
				num2 = GraphVars.Count;
			}
			int i;
			for (i = num; i < num2; i++)
			{
				Var var = (Var)GraphVars[i];
				CheckedSigVals value = checkedSigIx[i];
				switch (var.Format)
				{
				case ConfigBase.EStringFormat.e_X1:
				case ConfigBase.EStringFormat.e_X2:
				case ConfigBase.EStringFormat.e_X4:
				case ConfigBase.EStringFormat.e_X8:
				case ConfigBase.EStringFormat.e_Bin:
					empty = string.Format(ConfigBase.StrStringFormat[(uint)var.Format], (uint)var.data[myDataPos].Y);
					value.sigVal = string.Format("{0} {1}", empty, ConfigLiveView.SigClass[(int)var.SigClass].Unit);
					break;
				case ConfigBase.EStringFormat.e_F0:
				case ConfigBase.EStringFormat.e_F1:
				case ConfigBase.EStringFormat.e_F2:
				case ConfigBase.EStringFormat.e_F3:
					empty = string.Format(ConfigBase.StrStringFormat[(uint)var.Format], var.data[myDataPos].Y);
					value.sigVal = string.Format("{0} {1}", empty, ConfigLiveView.SigClass[(int)var.SigClass].Unit);
					break;
				default:
					value.sigVal = string.Empty;
					break;
				}
				checkedSigIx[i] = value;
			}
			checkedDataGridViewGraphSignals.Invoke((MethodInvoker)delegate
			{
				for (i = 0; i < checkedSigIx.Count; i++)
				{
					checkedDataGridViewGraphSignals.Rows[i].Cells[2].Value = checkedSigIx[i].sigVal;
				}
			});
		}

		private void buttonGraphMoveRight_Click(object sender, EventArgs e)
		{
			foreach (Function funct in functs)
			{
				if (funct.AB == ConfigData.e_ECUS.ECU_B)
				{
					NumberFormatInfo numberFormatInfo = new NumberFormatInfo();
					numberFormatInfo.NumberDecimalSeparator = ".";
					funct.Move((float)Convert.ToDouble(toolStripComboBoxStep.SelectedItem, numberFormatInfo));
				}
			}
			pictBox1.Focus();
			RedrawAll(true);
		}

		public void toolStripButtonFileInfo_Click(object sender, EventArgs e)
		{
			if (fileInfo != null)
			{
				fileInfo.ShowFileInfo();
			}
		}

		private void buttonGraphMoveLeft_Click(object sender, EventArgs e)
		{
			foreach (Function funct in functs)
			{
				if (funct.AB == ConfigData.e_ECUS.ECU_B)
				{
					NumberFormatInfo numberFormatInfo = new NumberFormatInfo();
					numberFormatInfo.NumberDecimalSeparator = ".";
					funct.Move((float)Convert.ToDouble(toolStripComboBoxStep.SelectedItem, numberFormatInfo) * -1f);
				}
			}
			pictBox1.Focus();
			RedrawAll(true);
		}

		public void toolStripButtonShiftEnabled(bool enable)
		{
			Invoke((MethodInvoker)delegate
			{
				toolStripButtonShiftLeft.Enabled = enable;
				toolStripButtonShiftRight.Enabled = enable;
			});
		}

		public void toolStripButtonExportEnabled(bool enable)
		{
			Invoke((MethodInvoker)delegate
			{
				toolStripButtonExport.Available = enable;
				toolStripButtonExport.Enabled = enable;
			});
		}

		protected void toolDataLogStripButtonExport_Click(object sender, EventArgs e)
		{
			INCA_Exporter iNCA_Exporter = new INCA_Exporter(myFileName, dataupdatetime);
			CSV_Exporter cSV_Exporter = new CSV_Exporter();
			if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphDataLog)
			{
				iNCA_Exporter.FileExport2ASCII(Path.ChangeExtension(myFileName, "ascii"), ref functs, ConfigData.EGraphicAspect.eShowGraphDataLog);
				cSV_Exporter.FileExport2CSV(Path.ChangeExtension(myFileName, "csv"), ref functs, ConfigData.EGraphicAspect.eShowGraphDataLog);
			}
			else if (graphicAspect == ConfigBase.EGraphicAspect.eShowGraphLiveViewRec || graphicAspect == ConfigBase.EGraphicAspect.eShowGraphLiveView)
			{
				iNCA_Exporter.FileExport2ASCII(Path.ChangeExtension(myFileName, "ascii"), ref functs, ConfigData.EGraphicAspect.eShowGraphShowLiveViewRec);
				cSV_Exporter.FileExport2CSV(Path.ChangeExtension(myFileName, "csv"), ref functs, ConfigData.EGraphicAspect.eShowGraphShowLiveViewRec);
			}
		}

		protected void showLeadInOut()
		{
			Console.WriteLine("showLeadInOut {0}", activeECU);
			switch (activeECU)
			{
			case ConfigData.e_ECUS.NO_ECU:
				leadInOutListA = new List<RecManLeadInOut.SLeadInOutInfo>();
				leadInOutListB = new List<RecManLeadInOut.SLeadInOutInfo>();
				if (serviceLayer.DatlogA.sLeadInLeadOut != null && serviceLayer.DatlogA.sLeadInLeadOut.listLeadInOutInfo != null)
				{
					leadInOutListA = serviceLayer.DatlogA.sLeadInLeadOut.listLeadInOutInfo;
				}
				if (serviceLayer.DatlogB.sLeadInLeadOut != null && serviceLayer.DatlogB.sLeadInLeadOut.listLeadInOutInfo != null)
				{
					leadInOutListB = serviceLayer.DatlogB.sLeadInLeadOut.listLeadInOutInfo;
				}
				if (toolStripComboBoxLeadinOut.ComboBox != null && toolStripComboBoxLeadinOut.Items.Count > 1)
				{
					toolStripComboBoxLeadinOut.Items.Clear();
				}
				break;
			case ConfigData.e_ECUS.ECU_A:
				if (leadInOutListA != null)
				{
					string[] array = new string[leadInOutListA.Count];
					if (toolStripComboBoxLeadinOut.Items.Count > 0)
					{
						toolStripComboBoxLeadinOut.Items.Clear();
					}
					for (int j = 0; j < leadInOutListA.Count; j++)
					{
						RecManLeadInOut.SLeadInOutInfo sLeadInOutInfo = leadInOutListA[j];
						array[j] = string.Format("A: {0} - {1}", sLeadInOutInfo.LeadInTime, sLeadInOutInfo.LeadOutTime);
					}
					toolStripComboBoxLeadinOut.Items.AddRange(array);
					toolStripComboBoxLeadinOut.Text = "LeadIn-Out Times";
				}
				break;
			case ConfigData.e_ECUS.ECU_B:
				if (leadInOutListB != null)
				{
					string[] array = new string[leadInOutListB.Count];
					if (toolStripComboBoxLeadinOut.Items.Count > 0)
					{
						toolStripComboBoxLeadinOut.Items.Clear();
					}
					for (int i = 0; i < leadInOutListB.Count; i++)
					{
						RecManLeadInOut.SLeadInOutInfo sLeadInOutInfo = leadInOutListB[i];
						array[i] = string.Format("B: {0} - {1}", sLeadInOutInfo.LeadInTime, sLeadInOutInfo.LeadOutTime);
					}
					toolStripComboBoxLeadinOut.Items.AddRange(array);
					toolStripComboBoxLeadinOut.Text = "LeadIn-Out Times";
				}
				break;
			}
		}

		private void GoToLeadInOutPos(int index)
		{
			int num = 0;
			if (activeECU == ConfigData.e_ECUS.ECU_A)
			{
				for (int i = 0; i < index; i++)
				{
					num += leadInOutListA[i].dataCnt;
					num += 10;
				}
			}
			else if (activeECU == ConfigData.e_ECUS.ECU_B)
			{
				for (int j = 0; j < index; j++)
				{
					num += leadInOutListB[j].dataCnt;
					num += 10;
				}
			}
			num -= 10;
			Console.WriteLine("B: cnt = {0}", num);
			if (num <= 0)
			{
				num = 0;
			}
			GraphMoveLeftRight(num);
		}

		private void ev_GoToLeadInOutPos(object sender, EventArgs e)
		{
			if (toolStripComboBoxLeadinOut.Items.Count > 0)
			{
				Console.WriteLine("base.toolStripComboBoxLeadinOut.SelectedIndex = {0}", toolStripComboBoxLeadinOut.SelectedIndex);
				if (toolStripComboBoxLeadinOut.SelectedIndex >= 0)
				{
					GoToLeadInOutPos(toolStripComboBoxLeadinOut.SelectedIndex);
				}
			}
		}

		private void GraphMoveLeftRight(int newPos)
		{
			int num = -newPos;
			int num2 = num - hScrollBar1.Value;
			if (num2 > 0)
			{
				lock (koordsysts.SyncRoot)
				{
					Koordsyst koordsyst5 = (Koordsyst)koordsysts[0];
					foreach (Koordsyst koordsyst3 in koordsysts)
					{
						koordsyst3.offsetWert(num2, 0f);
					}
					if (num > hScrollBar1.Maximum)
					{
						hScrollBar1.Value = hScrollBar1.Maximum;
					}
					else
					{
						hScrollBar1.Value = num;
					}
				}
				RedrawAll(true);
			}
			else if (num2 < 0)
			{
				lock (koordsysts.SyncRoot)
				{
					Koordsyst koordsyst6 = (Koordsyst)koordsysts[0];
					foreach (Koordsyst koordsyst4 in koordsysts)
					{
						koordsyst4.offsetWert(num2, 0f);
					}
					if (num < hScrollBar1.Minimum)
					{
						hScrollBar1.Value = hScrollBar1.Minimum;
					}
					else
					{
						hScrollBar1.Value = num;
					}
				}
			}
			RedrawAll(true);
		}
	}
}
